home *** CD-ROM | disk | FTP | other *** search
- Path: ppp58.micronet.fr!user
- From: fgrieu@micronet.fr (Franτois Grieu)
- Newsgroups: comp.arch.arithmetic,comp.lang.c,comp.lang.c++
- Subject: Re: Access carry flag from C
- Date: Fri, 08 Mar 1996 14:32:57 +0100
- Organization: Innovatron
- Message-ID: <fgrieu-0803961432570001@ppp58.micronet.fr>
- References: <Dn1C9z.DGv.0.net@indra.com> <825377932snz@genesis.demon.co.uk> <4h1veoINNlns@anvil.ugrad.cs.ubc.ca> <fgrieu-0403961143580001@ppp78.micronet.fr> <4hhbt8$1d3o@b.stat.purdue.edu>
- NNTP-Posting-Host: ppp58.micronet.fr
- X-Newsreader: Yet Another NewsWatcher 2.1.2
-
- In article <4hhbt8$1d3o@b.stat.purdue.edu>, hrubin@b.stat.purdue.edu
- (Herman Rubin) wrote:
-
- > Notice that in (original code: fgrieu-0403961143580001@ppp78.micronet.fr)
- > each addition must be performed twice.
-
-
- Silly of me. This extra addition can be avoided entirely, as well as
- any temporary variable. The following, improved trick should works just as
- fine, for the purprose of doing multiple precision addition in a quite
- portable manner.
-
-
- unsigned long yl,yh; /* double_unsigned_long_int y */
- unsigned long x;
-
- /* add x to double_unsigned_long_int y */
- yl += x;
- if (yl < x) ++yh; /* test if overflow occured on previous line */
-
- the adventurous can even try
- if ((yl += x) < x) ++yh; /* add x to double_unsigned_long_int y */
-
- --
- Francois Grieu email:fgrieu@micronet.fr
-